/* global alert */
export default {
  title: 'elfTodos',
  apiPath: 'http://elftodo.localhost/api',
  cloneItem (item) {
    let obj = {}
    for (let key in item) {
      obj[key] = item[key]
    }
    return obj
  },
  itemEquals (item1, item2) {
    for (let key in item1) {
      if (item1[key] === item2[key]) {
        continue
      }
      return false
    }
    return true
  },
  ensureLogin (rootVm) {
    if (!rootVm) {
      alert('invalid function call, please contact admin!\nAnd please go to login page to sign in your session.')
      return false
    }
    if (!rootVm.user.name) {
      rootVm.$router.go('/login')
      return false
    }
    return true
  }
}
